package com.gareve.twoSides.models;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.Vector2;
import com.gareve.twoSides.GameConstants;

public class PlayerObject extends GameObject{
	public static final float WIDTH = 5f;
	public static final float HEIGHT = 5f;
	
	private static final Color CRASH_COLOR = new Color(1f, 0f, 0f, 1f);
	private static final Color NORMAL_COLOR = new Color(0f, 1f, 0f, 1f);
	public boolean crashed;
	
	Vector2 target;

	public PlayerObject(float x, float y) {
		super(x, y, WIDTH,HEIGHT);
		crashed = false;
		target = null;
	}

	public void move(Vector2 direction) {
		shape.x += direction.x * GameConstants.PLAYER_OBJECT_SPEED;
		shape.y += direction.y * GameConstants.PLAYER_OBJECT_SPEED;
	}
	
	public void setTarget(Vector2 target){
		this.target = target;
	}
	
	public void render(ShapeRenderer shapeRenderer){
		shapeRenderer.begin(ShapeType.Rectangle);
			shapeRenderer.setColor(crashed?CRASH_COLOR:NORMAL_COLOR);
			shapeRenderer.rect(shape.x, shape.y, shape.width, shape.height);
		shapeRenderer.end();
	}
}
